package cn.ywang.spring.customized.demo.action;


import cn.ywang.spring.customized.demo.service.IDemoService;
import cn.ywang.spring.customized.framework.annotation.Autowired;
import cn.ywang.spring.customized.framework.annotation.Controller;
import cn.ywang.spring.customized.framework.annotation.RequestMapping;
import cn.ywang.spring.customized.framework.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author BeatificWang
 */
@Controller
@RequestMapping("/web")
public class DemoAction {

	@Autowired
	IDemoService demoService;

	@RequestMapping("/query.json")
	public void query(HttpServletRequest req, HttpServletResponse resp,
	                  @RequestParam("name") String name) {
		String result = this.demoService.get(name);
		try {
			resp.getWriter().write(result);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@RequestMapping("/edit.json")
	public void edit(HttpServletRequest req, HttpServletResponse resp, Integer id) {

	}

}
